/*
 * @Author: Broin
 * @Date: 2021-12-12 22:49:50
 * @LastEditTime: 2021-12-12 23:16:04
 * @LastEditors: your name
 * @Description: 测试ssh 是否可用.
 * @FilePath: /ac_interface/test/ssh.js
 * MADE BY BROIN
 */


const { readFileSync } = require('fs');

const { Client } = require('ssh2');

const conn = new Client();
conn.on('ready', () => {
  console.log('Client :: ready');
  conn.shell((err, stream) => {
    if (err) throw err;
    stream.on('close', () => {
      console.log('Stream :: close');
      conn.end();
    }).on('data', (data) => {
      console.log('OUTPUT: ' + data);
    });
    stream.end('ls -l\nexit\n');
  });
}).connect({
  host: '172.21.4.216',
  port: 22,
  username: 'root',
  password: 'Nibushiwo351351'
});